<template>
  <div>
    <div class="crumbs">
      <el-breadcrumb separator="/">
        <el-breadcrumb-item>
          <router-link to="/customer/customerNews">客户管理</router-link>
        </el-breadcrumb-item>
        <el-breadcrumb-item>客户详情</el-breadcrumb-item>
      </el-breadcrumb>
    </div>
    <basic-container>
      <template>
        <el-row class="new_top">
          <el-col :span="2">
            <el-image :src="avatar"></el-image>
          </el-col>
          <el-col :span="17" class="news">
            <el-row style="font-size: 18px;">
              <el-col :span="12">{{detail.customerName}}</el-col>
              <el-col :span="12" class="text-right">
                <el-button size="small" @click="goEdit()">编辑客户</el-button>
              </el-col>
            </el-row>
            <el-row>
              <el-col :span="12">
                <span>客户编码：{{detail.customerSn}}</span>
              </el-col>
              <el-col :span="12">
                <span>客户类型：{{detail.customerType == 1 ? '经销商' : '门店'}}</span>
              </el-col>
            </el-row>
            <el-row>
              <el-col :span="12">
                <span>联系人：{{detail.contact}}</span>
              </el-col>
              <el-col :span="12">
                <span>标注地址：{{detail.address}}</span>
              </el-col>
            </el-row>
            <el-row>
              <el-col :span="12">
                <span>创建时间：{{detail.registrationDate}}</span>
              </el-col>
            </el-row>
          </el-col>
        </el-row>
      </template>
    </basic-container>
    <!-- 业务动态 -->
    <basic-container>
      <template>
        <el-row class="de_new">
          <!-- 左边动态 -->
          <el-col :span="15" style="float: left">
            <el-tabs v-model="leftName" @tab-click="handleClick">
              <el-tab-pane label="业务动态" name="first">
                <div>
                  <!-- <el-select
                    v-if="dynamicList.length > 0"
                    filterable
                    clearable
                    @change="handleDynamic"
                    v-model="value"
                    placeholder="请选择"
                    style="margin-bottom:15px;"
                  >
                    <el-option
                      v-for="item in options"
                      :key="item.value"
                      :label="item.label"
                      :value="item.value"
                    ></el-option>
                  </el-select>-->
                  <!-- <div class="blockData">
                    <span class="demonstration">搜索业务动态：</span>
                    <el-date-picker
                      v-model="dynamicList"
                      type="daterange"
                      format="yyyy-MM"
                      value-format="yyyy-MM"
                      @change="changeAnalyticsTime"
                      unlink-panels
                      range-separator="至"
                      start-placeholder="开始日期"
                      end-placeholder="结束日期"
                    ></el-date-picker>
                  </div>-->
                  <div class="blockData">
                    <span class="demonstration">搜索业务动态：</span>
                    <el-date-picker
                      class="picker"
                      v-model="value2"
                      type="daterange"
                      format="yyyy-MM-dd"
                      value-format="yyyy-MM-dd"
                      @change="changeBusinessTime"
                      range-separator="至"
                      start-placeholder="开始日期"
                      end-placeholder="结束日期"
                    ></el-date-picker>
                  </div>
                  <div class="block">
                    <el-timeline>
                      <el-timeline-item
                        v-for="(item, index) in dynamicList"
                        :key="index"
                        :timestamp="item.createDate"
                        placement="top"
                      >
                        <el-card>
                          <h3 @click="salesOrder(item.sourceSn)">{{item.stateType==1 ? '销售订单' : ''}}</h3>
                          <h3
                            @click="salesReport(item.sourceSn)"
                          >{{item.stateType==2 ? '销量上报' : ''}}</h3>
                          <h3
                            @click="stockReport(item.sourceSn)"
                          >{{item.stateType==3 ? '库存上报' : ''}}</h3>
                          <h3
                            @click="productsReport(item.sourceSn)"
                          >{{item.stateType==4 ? '竞品上报' : ''}}</h3>
                          <h3 @click="stateType(item.sourceSn)">{{item.stateType==5 ? '客户采购' : ''}}</h3>
                          <h4>{{item.content}}</h4>
                          <p>{{item.reportMan}}</p>
                        </el-card>
                      </el-timeline-item>
                    </el-timeline>
                  </div>
                </div>
                <div v-show="dynamicList.length == 0">无业务动态</div>
                <div class="block">
                  <el-pagination
                    :data="dynamicList"
                    @size-change="handleSizeChange"
                    @current-change="handleCurrentChange"
                    :page.sync="page"
                    :page-sizes="[10, 20, 30, 40]"
                    :page-size="2"
                    :total="page.total"
                    layout="total, sizes, prev, pager, next, jumper"
                  ></el-pagination>
                </div>
              </el-tab-pane>
              <el-tab-pane label="客户画像" class="send_bor" name="second">
                <div class="s_bor">
                  客户标签：
                  <span v-if="labelList.length > 0">
                    <el-tag v-for="(item, index) in labelList" :key="index">{{item}}</el-tag>
                  </span>
                  <span v-else>无</span>
                  <!-- <el-tag>人脉广</el-tag><el-tag type="success">不差钱</el-tag><el-tag type="info">时间多</el-tag><el-tag type="warning">年轻</el-tag><el-tag type="danger">个子高</el-tag> -->
                </div>
                <div class="s_bor">
                  <span>总订单数量：{{summary.orderNum ? summary.orderNum + '笔' : ''}}</span>
                  <span>总销售额：{{summary.orderAmount ? summary.orderAmount + '元' : ''}}</span>
                </div>
                <div>
                  <div class="send_t">
                    <h3>拜访分析</h3>
                    <el-date-picker
                      class="picker"
                      v-model="value1"
                      type="monthrange"
                      format="yyyy-MM"
                      value-format="yyyy-MM"
                      @change="changeAnalyticsTime"
                      range-separator="至"
                      start-placeholder="开始日期"
                      end-placeholder="结束日期"
                    ></el-date-picker>
                  </div>
                  <avue-echart-line :theme="theme" :option="option" :data="analyticsData"></avue-echart-line>
                </div>
              </el-tab-pane>
              <el-tab-pane label="客户详情" style="overflow: hidden" name="third">
                <user-detail :detail="detail" />
              </el-tab-pane>
            </el-tabs>
          </el-col>
          <!-- 右边相关内容 -->
          <el-col :span="6" style="float: right">
            <el-tabs v-model="rightName" @tab-click="rightClick">
              <el-tab-pane label="相关" name="first">
                <el-collapse accordion>
                  <el-collapse-item style="height: auto;">
                    <template slot="title">
                      <div class="collapse_title">
                        <el-avatar
                          style="float: left;margin-top: 3px;margin-right: 10px"
                          src="/img/crm/linkman.png"
                        ></el-avatar>
                        <span style="float: left">联系人({{manList.length}})</span>
                      </div>
                    </template>
                    <div class="add_linkman">
                      <i class="header-icon el-icon-plus" @click="add_linkman"></i>
                    </div>
                    <div class="collapse_div" v-for="item in manList">
                      <p>姓名：{{item.name}}</p>
                      <p>手机：{{item.telephone}}</p>
                      <p>职位：{{item.position}}</p>
                      <p>邮箱：{{item.email}}</p>
                      <p v-if="item.sex == 1">性别：男</p>
                      <p v-if="item.sex == 2">性别：女</p>
                      <p>是否主要联系人：{{item.primaryFlag === '1' ? '是' : '否'}}</p>
                      <p>备注：{{item.remarks}}</p>
                      <span>
                        <i class="el-icon-edit" @click="show_manVisible(item)"></i>
                        <i class="el-icon-delete" @click="del_linkman(item)"></i>
                      </span>
                    </div>
                    <el-dialog :title="manTitle" :visible.sync="manVisible" width="45%">
                      <el-form ref="form" :model="form" label-width="120px">
                        <el-form-item label="姓名">
                          <el-input v-model="form.name"></el-input>
                        </el-form-item>
                        <el-form-item label="手机">
                          <el-input v-model="form.telephone"></el-input>
                        </el-form-item>
                        <el-form-item label="职位">
                          <el-input v-model="form.position"></el-input>
                        </el-form-item>
                        <el-form-item label="地址">
                          <el-input v-model="form.address"></el-input>
                        </el-form-item>
                        <el-form-item label="邮箱">
                          <el-input v-model="form.email" type="email"></el-input>
                        </el-form-item>
                        <el-form-item label="是否主要联系人">
                          <el-switch
                            v-model="form.primaryFlag"
                            active-color="#13ce66"
                            inactive-color="#ff4949"
                            active-value="1"
                            inactive-value="0"
                            active-text="是"
                            inactive-text="否"
                          ></el-switch>
                        </el-form-item>
                        <el-form-item label="性别">
                          <el-switch
                            v-model="form.sex"
                            active-color="#13ce66"
                            inactive-color="#ff4949"
                            active-value="1"
                            inactive-value="2"
                            active-text="男"
                            inactive-text="女"
                          ></el-switch>
                        </el-form-item>
                        <el-form-item label="备注">
                          <el-input type="textarea" v-model="form.remarks"></el-input>
                        </el-form-item>
                        <el-form-item>
                          <el-button @click="manVisible = false">取 消</el-button>
                          <el-button type="primary" @click="save_form">确 定</el-button>
                        </el-form-item>
                      </el-form>
                    </el-dialog>
                  </el-collapse-item>
                </el-collapse>
              </el-tab-pane>
              <el-tab-pane label="地址" name="send">
                <el-collapse accordion>
                  <el-collapse-item>
                    <template slot="title">
                      <div class="collapse_title">
                        <el-avatar
                          style="float: left;margin-top: 3px;margin-right: 10px"
                          src="/img/crm/linkman.png"
                        ></el-avatar>
                        <span style="float: left">收货方({{addressList.length}})</span>
                      </div>
                    </template>
                    <div class="add_linkman">
                      <i class="header-icon el-icon-plus" @click="add_address"></i>
                    </div>
                    <div class="collapse_div" v-for="item in addressList">
                      <p>联系人：{{item.linkman}}</p>
                      <p>联系电话：{{item.telephone}}</p>
                      <p>位置：{{item.province}}{{item.city}}{{item.district}}{{item.street}}</p>
                      <p>详细地址：{{item.address}}</p>
                      <p v-if="item.defaultFlag == 1">是否默认：是</p>
                      <p v-else>是否默认：否</p>
                      <span>
                        <i class="el-icon-edit" @click="show_addressVisible(item)"></i>
                        <i class="el-icon-delete" @click="del_address(item)"></i>
                      </span>
                    </div>
                    <el-dialog :title="addressTitle" :visible.sync="addressVisible" width="45%">
                      <el-form ref="form" :model="addressForm" label-width="80px">
                        <el-form-item label="联系人">
                          <el-select
                            v-model="addressForm.linkman"
                            style="width: 100%"
                            @change="selectLinkMan"
                            placeholder="请选择联系人"
                          >
                            <el-option
                              v-for="item in manList"
                              :key="item.id"
                              :label="item.name"
                              :value="item.name"
                            ></el-option>
                          </el-select>
                        </el-form-item>
                        <el-form-item label="手机">
                          <el-input v-model="addressForm.telephone" type="tel" maxlength="11"></el-input>
                        </el-form-item>
                        <el-form-item label="标注位置">
                          <p style="text-align: left">{{position.formattedAddress}}</p>
                          <avue-map v-model="position" style="width:200px" :lnglat="lnglat"></avue-map>
                        </el-form-item>
                        <el-form-item label="详细地址">
                          <el-input v-model="addressForm.address"></el-input>
                        </el-form-item>
                        <el-form-item label="是否默认">
                          <el-switch
                            v-model="addressForm.defaultFlag"
                            active-color="#13ce66"
                            inactive-color="#ff4949"
                            active-value="1"
                            inactive-value="0"
                            active-text="是"
                            inactive-text="否"
                          ></el-switch>
                        </el-form-item>
                        <el-form-item label="备注">
                          <el-input type="textarea" v-model="addressForm.remarks"></el-input>
                        </el-form-item>
                        <el-form-item>
                          <el-button @click="addressVisible = false">取 消</el-button>
                          <el-button type="primary" @click="save_address">确 定</el-button>
                        </el-form-item>
                      </el-form>
                    </el-dialog>
                  </el-collapse-item>
                </el-collapse>
              </el-tab-pane>
              <el-tab-pane label="日志" name="second">
                <div class="log" v-for="item in logList">
                  {{item.operatorName}}修改{{item.customerName}}的{{item.remarks}}：{{item.updateBefore}}为{{item.updateAfter}}
                  <div>{{item.opTime}}</div>
                </div>
              </el-tab-pane>
            </el-tabs>
          </el-col>
        </el-row>
      </template>
      <!-- <div class="block">
        <el-pagination
          :data="dynamicList"
          @size-change="handleSizeChange"
          @current-change="handleCurrentChange"
          :page.sync="page"
          :page-sizes="[10, 20, 30, 40]"
          :page-size="2"
          :total="page.total"
          layout="total, sizes, prev, pager, next, jumper"
        ></el-pagination>
      </div>-->
    </basic-container>
  </div>
</template>

<script>
import { getDetail } from "@/api/crm/customerList";
import { fetchList } from "@/api/crm/customerupdatelog"; //日志
import { getMonthAnalysis, getSummaryAnalysis } from "@/api/crm/customervisit";
import {
  fetchList as linkman,
  putObj,
  addObj,
  delObj
} from "@/api/crm/customerlinkman"; //联系人
import { fetchList as getCustomerDynamic } from "@/api/crm/customerdynamicstate"; // 客户动态
import {
  fetchList as address,
  addObj as addObjaddress,
  putObj as putObjaddress,
  delObj as delObjaddress
} from "@/api/crm/customeraddress"; //地址
import userDetail from "./userDetail.vue";
import { goBack } from "../../../util/util";

export default {
  name: "detail",
  data() {
    return {
      customerSn: "",
      detail: {},
      leftName: "first",
      rightName: "first",
      // option1: [
      //   {
      //     value: "1",
      //     label: "销售订单"
      //   },
      //   {
      //     value: "2",
      //     label: "销量上报"
      //   },
      //   {
      //     value: "3",
      //     label: "库存上报"
      //   },
      //   {
      //     value: "4",
      //     label: "竞品上报"
      //   },
      //   {
      //     value: "5",
      //     label: "客户采购"
      //   }
      // ],
      startDate: "",
      value: "",
      theme: "",
      analyticsData: this.getAnalyticsData(),
      option: {
        switchTheme: true,
        width: 1200,
        height: 600,
        title: "手机大比拼",
        smooth: true, //是否顺滑
        areaStyle: true //是否面积
      },
      value1: "",
      value2: "",
      logList: [],
      manList: [],
      addressList: [],
      manVisible: false,
      manTitle: "",
      form: {},
      link_type: "",
      addressVisible: false,
      addressTitle: "",
      addressForm: {},
      page: {
        total: 0, // 总页数
        currentPage: 1, // 当前页数
        pageSize: 10 // 每页显示多少条
      },
      //初始化坐标
      lnglat: {
        P: 29.563761,
        R: 106.55046400000003
      },
      position: {
        formattedAddress: "",
        addressComponent: {
          city: "",
          district: "",
          province: "",
          township: ""
        },
        longitude: "",
        longitude: ""
      },
      endDate: "",
      startDate: "",
      businessList: [],
      dynamicList: [],
      labelList: [],
      avatar: "/img/crm/default-customer.jpg",
      summary: {}
    };
  },
  components: {
    userDetail
  },
  created() {
    // this.detail = this.$route.query;
    // this.init();
    // this.getCustomerDynamicByParams(this.page);
    // this.getMonthAnalysisByParams();
    // this.getSummaryAnalysisByParams();
  },

  beforeRouteEnter(to, from, next) {
    next(vm => vm.init(vm.$route.query.res.customerSn));
  },
  methods: {
    handleSizeChange(val) {
      console.log(`每页 ${val} 条`);
      let page = {
        ...this.page,
        pageSize: val || 10,
        currentPage: 1
      };
      this.getCustomerDynamicByParams(page);
    },
    handleCurrentChange(currentPage) {
      let page = {
        ...this.page,
        currentPage: currentPage,
        endDate: this.endDate,
        startDate: this.startDate
      };
      this.getCustomerDynamicByParams(page);
      console.log(`当前页: ${currentPage}`);
    },
    // 客户采购跳转到平台采购供应订单详情页
    stateType(sourceSn) {
      console.log(sourceSn);
      let buyOrderSn = sourceSn;
      let query = {
        res: {
          buyOrderSn: buyOrderSn,
          customerSn: this.customerSn
        }
      };
      console.log(query);
      this.$router.push({
        path: "/supply/purchasedeatilssupplygoods",
        query: query
      });
    },
    // 销售上报跳转到销售上报详情页,接收cr
    salesReport(sourceSn) {
      console.log(sourceSn);
      let reportSn = sourceSn;
      let query = {
        res: {
          reportSn: reportSn,
          customerSn: this.customerSn
        }
      };
      console.log(query);
      this.$router.push({
        path: "/reporting/salesDetail",
        query: query
      });
    },
    // 库存上报跳转到库存上报详情页,接收cr
    stockReport(sourceSn) {
      console.log(sourceSn);
      let reportSn = sourceSn;
      let query = {
        res: {
          reportSn: reportSn,
          customerSn: this.customerSn
        }
      };
      console.log(query);
      this.$router.push({
        path: "/reporting/inventoryDetail",
        query: query
      });
    },

    // 竞品上报跳转到销售上报详情页,接收cr
    productsReport(sourceSn) {
      console.log(sourceSn);
      let reportSn = sourceSn;
      let query = {
        res: {
          reportSn: reportSn,
          customerSn: this.customerSn
        }
      };
      console.log(query);
      this.$router.push({
        path: "/reporting/competitionDetail",
        query: query
      });
    },
    // 销售订单跳转到销售订单详情页,接收or
    salesOrder(sourceSn) {
      console.log(sourceSn);
      let salesOrderSn = sourceSn;
      let query = {
        res: {
          salesOrderSn: salesOrderSn,
          customerSn: this.customerSn
        }
      };
      console.log(query);
      this.$router.push({
        path: "/orderCon/salesOrderDetail",
        query: query
      });
    },

    init(customerSn) {
      // let srcPage = sessionStorage.getItem("srcPage");
      // sessionStorage.removeItem("srcPage");
      // if (srcPage != "back") {
      if (!customerSn) {
        return ;
      }
      let params = {
        customerSn: customerSn
      };
      this.customerSn = customerSn;
      getDetail(params).then(res => {
        this.detail = res.data.data;
        this.labelList = this.detail.tags ? this.detail.tags.split(",") : [];
        if (this.detail.photoList.length > 0)
          this.avatar = this.detail.photoList[0].picUrl;
      });
      //获取客户日志
      fetchList(params).then(res => {
        this.logList = res.data.data.records;
      });
      // 地址
      linkman({ customerSn: this.customerSn, current: 1, size: 50 }).then(
        res => {
          this.manList = res.data.data.records;
        }
      );
      address(
        {
          customerSn: this.customerSn,
          current: 1,
          size: 50
        },
        params
      )
        .then(res => {
          this.addressList = res.data.data.records;
        })
        .catch(() => {
          this.goBack();
        });
      this.getCustomerDynamicByParams(this.page);
      this.getMonthAnalysisByParams({});
      // }
    },
    goBack(time = 1000) {
      goBack(this, time);
    },
    // 客户画像
    async getSummaryAnalysisByParams(customerSn) {
      let res = await getSummaryAnalysis(customerSn);
      this.summary = res.data.data;
    },
    // 业务动态
    async getCustomerDynamicByParams(query) {
      let params = {
        customerSn: this.customerSn,
        current: query.currentPage,
        size: query.pageSize,
        endDate: query.endDate,
        startDate: query.startDate
      };
      let res = await getCustomerDynamic(params);
      this.dynamicList = res.data.data.records;

      this.page = {
        total: res.data.data.total,
        currentPage: res.data.data.current,
        pageSize: res.data.data.size
      };
    },
    // 选择日期业务动态事件
    // handleDynamic(value) {
    //   let page = {
    //     pageSize: this.page.pageSize,
    //     currentPage: 1
    //   };
    //   this.getCustomerDynamicByParams(page, value);
    //   console.log(value);
    // },
    // 客户画像里面的日期
    changeAnalyticsTime(data) {
      console.log(data);
      let params = {};
      if (Array.isArray(data) && data.length === 2) {
        params.startDate = data[0];
        params.endDate = data[1];
      }
      this.getMonthAnalysisByParams(params);
    },
    // 业务动态日期
    async changeBusinessTime(data) {
      let Obj = {};
      if (Array.isArray(data) && data.length === 2) {
        Obj.startDate = data[0];
        Obj.endDate = data[1];
      }
      this.endDate = Obj.endDate;
      this.startDate = Obj.startDate;
      let query = {
        ...this.page,
        currentPage: 1,
        endDate: Obj.endDate,
        startDate: Obj.startDate
      };
      console.log(query);
      this.getCustomerDynamicByParams(query);
    },
    async getMonthAnalysisByParams(query) {
      let params = {
        customerSn: this.customerSn,
        endDate: query.endDate,
        startDate: query.startDate
      };
      let res = await getMonthAnalysis(params);
      let analyticsList = res.data.data.analysisList;
      this.analyticsData = this.getAnalyticsData();
      analyticsList.map(item => {
        this.analyticsData.categories.push(item.month);
        this.analyticsData.series[0].data.push(item.num);
      });
    },
    // getCustomerSn() {
    //   return JSON.parse(this.$route.query.res).customerSn;
    // },
    //显示编辑联系人弹窗
    show_manVisible(row) {
      this.manVisible = true;
      this.manTitle = "编辑联系人";
      this.form = row;
      this.link_type = 0;
    },
    // 编辑
    goEdit() {
      let query = {
        res: JSON.stringify(this.detail)
      };
      this.$router.push({
        path: "/customer/editCustomer",
        query: query
      });
    },
    //添加联系人
    add_linkman() {
      this.manVisible = true;
      this.manTitle = "新增联系人";
      this.form = {
        primaryFlag: "1",
        sex: "1"
      };
      this.link_type = 1;
    },
    //编辑客户联系人
    save_form() {
      if (this.link_type == 0) {
        putObj(this.form).then(data => {
          this.$message({
            showClose: true,
            message: "修改成功",
            type: "success"
          });
          this.manVisible = false;
          this.init();
        });
      } else {
        this.form.customerSn = JSON.parse(this.$route.query.res).customerSn;
        addObj(this.form).then(data => {
          this.$message({
            showClose: true,
            message: "添加成功",
            type: "success"
          });
          this.manVisible = false;
          this.init();
        });
      }
    },
    //删除联系人
    del_linkman(row) {
      var _this = this;
      this.$confirm("是否确认删除联系人" + row.name, "提示", {
        confirmButtonText: "确定",
        cancelButtonText: "取消",
        type: "warning"
      })
        .then(function() {
          return delObj(row.id);
        })
        .then(data => {
          _this.$message({
            showClose: true,
            message: "删除成功",
            type: "success"
          });
          this.init(this.page);
        })
        .catch(function(err) {});
    },
    //显示地址弹窗
    show_addressVisible(row) {
      this.addressVisible = true;
      this.addressTitle = "编辑地址";
      this.addressForm = row;
      this.position.formattedAddress =
        row.province + row.city + row.district + row.street;
      this.position.addressComponent.province = row.province;
      this.position.addressComponent.city = row.city;
      this.position.addressComponent.district = row.district;
      this.position.addressComponent.township = row.street;
      let tmp = row.position.split(",");
      this.lnglat = { P: Number(tmp[1]), R: Number(tmp[0]) };
      this.link_type = 0;
    },
    //添加地址
    add_address() {
      this.addressVisible = true;
      this.addressTitle = "新增地址";
      this.addressForm = {
        defaultFlag: "1"
      };
      this.link_type = 1;
    },
    selectLinkMan(name) {
      this.manList.forEach(item => {
        if (item.name === name) {
          this.addressForm.telephone = item.telephone;
        }
      });
    },
    save_address() {
      let params = this.addressForm;
      params.position = this.position.longitude + "," + this.position.latitude;
      params.province = this.position.addressComponent.province;
      if (
        params.province === "重庆市" ||
        params.province === "北京市" ||
        params.province === "上海市" ||
        params.province === "天津市" ||
        params.province === "香港特别行政区" ||
        params.province === "澳门特别行政区"
      ) {
        params.city = params.province;
      } else {
        params.city = this.position.addressComponent.city;
      }

      params.district = this.position.addressComponent.district;
      params.street = this.position.addressComponent.township;
      params.customerSn = JSON.parse(this.$route.query.res).customerSn;
      if (this.link_type == 0) {
        putObjaddress(params).then(data => {
          this.$message({
            showClose: true,
            message: "修改成功",
            type: "success"
          });
          this.addressVisible = false;
          this.init();
        });
      } else {
        addObjaddress(this.addressForm).then(data => {
          this.$message({
            showClose: true,
            message: "添加成功",
            type: "success"
          });
          this.addressVisible = false;
          this.init();
        });
      }
    },
    //删除地址
    del_address(row) {
      var _this = this;
      this.$confirm("是否确认删除" + row.linkman + "的地址", "提示", {
        confirmButtonText: "确定",
        cancelButtonText: "取消",
        type: "warning"
      })
        .then(function() {
          return delObjaddress(row.id);
        })
        .then(data => {
          _this.$message({
            showClose: true,
            message: "删除成功",
            type: "success"
          });
          this.init(this.page);
        })
        .catch(function(err) {});
    },
    close() {
      this.$router.go(-1);
    },
    handleClick(tab, event) {
      // console.log(tab, event);
    },
    rightClick(tab, event) {
      // console.log(tab, event);
    },
    getAnalyticsData() {
      return {
        categories: [],
        series: [
          {
            name: "拜访次数",
            data: []
          }
        ]
      };
    }
  }
};
</script>

<style scoped lang="scss">
.crumbs {
  margin: 20px 10px;
}
.new_top {
  padding: 0 20px;
}
.block {
  padding-right: 10px;
}
.blockData {
  margin-bottom: 20px;
}
.news {
  text-align: left;
  padding: 10px 15px;
  line-height: 25px;
}
.de_new .el-col {
  margin: 0 30px;
}
.send_bor .s_bor {
  border-bottom: 1px solid #eee;
  padding: 20px 0;
}
.send_bor .s_bor span {
  display: inline-block;
  width: 33%;
}
.send_bor .s_bor .el-tag {
  margin-right: 30px;
  width: auto;
}
.send_t {
  overflow: hidden;
  padding-top: 15px;
}
.send_t h3 {
  float: left;
}
.send_t .picker {
  float: right;
  min-width: 380px;
}
.detail_l {
  width: 46%;
  float: left;
  margin-right: 4%;
  border-bottom: 1px solid #eee;
}
.detail_l h4 {
  font-size: 18px;
  padding: 5px 0;
  color: #888;
}
.detail_l p {
  padding-bottom: 20px;
}
.collapse_div {
  position: relative;
  margin-top: 10px;
  padding-top: 15px;
  border-top: 1px solid #ddd;
}
.collapse_div span {
  position: absolute;
  top: 8%;
  right: 0;
  font-size: 16px;
}
.collapse_div span i {
  margin-left: 10px;
  cursor: pointer;
}
.log {
  padding: 10px 0;
  border-bottom: 1px solid #eeeeee;
}
.el-icon-plus {
  float: right;
  margin-top: 20px;
}
.el-collapse-item .el-collapse-item__header {
  height: auto;
}
.add_linkman {
  position: absolute;
  top: 0;
  font-size: 18px;
  right: 0;
  cursor: pointer;
}
</style>


